﻿namespace Raven
{
    public class InvertedAABBox2D
    {
        private Vector2 m_vTopLeft;
        private Vector2 m_vBottomRight;
        private Vector2 m_vCenter;

        public InvertedAABBox2D(Vector2 tl,
            Vector2 br)
        {
            m_vTopLeft = tl;
            m_vBottomRight = br;
            m_vCenter = (tl + br) / 2;
        }

        public Fix Top()
        {
            return m_vTopLeft.y;
        }

        public Fix Left()
        {
            return m_vTopLeft.x;
        }

        public Fix Bottom()
        {
            return m_vBottomRight.y;
        }

        public Fix Right()
        {
            return m_vBottomRight.x;
        }

        //returns true if the bbox described by other intersects with this one
        public bool isOverlappedWith(InvertedAABBox2D other)
        {
            return !((other.Top() > this.Bottom()) ||
                     (other.Bottom() < this.Top()) ||
                     (other.Left() > this.Right()) ||
                     (other.Right() < this.Left()));
        }
    }
}